package com.dfd.store.web.servlet;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dfd.store.domain.Category;
import com.dfd.store.domain.Product;
import com.dfd.store.service.CategoryService;
import com.dfd.store.service.ProductService;
import com.dfd.store.service.impl.CategoryServiceImpl;
import com.dfd.store.service.impl.ProductServiceImpl;
import com.dfd.store.web.base.BaseServlet;

public class IndexServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;

	@Override
	public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
		// // 调用业务层功能,获取全部分类信息
		// CategoryService categoryservice = new CategoryServiceImpl();
		// List<Category> list = categoryservice.getAllCats();
		// // 将返回的集合放入request
		// request.setAttribute("allCats", list);
		// 调用业务层查询最新商品,查询最热商品,返回两个集合
		ProductService productService = new ProductServiceImpl();
		List<Product> list01 = productService.findHots();
		List<Product> list02 = productService.findNews();
		// 将2个集合放到request下
		request.setAttribute("hots", list01);
		request.setAttribute("news", list02);
		// 转发到真实的首页
		return "/jsp/index.jsp";
	}
}
